//////////////////////////////////
///生成时间:2012-03-05 15:01:58
///BaseModel:系统用户(Sys_User)(Sys_User)
//////////////////////////////////
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace yule.Model.Base.Sys
{
    /// <summary>
    /// 系统用户(Sys_User) (Sys_User)
    /// </summary>
    [DataContract]
    [Serializable]
    public abstract class User : yule.Model.IModel<yule.Model.Sys.User>
    {
        #region 属性

        /// <summary>
        /// 主键
        /// </summary>
        private dynamic _Id = null;
        /// <summary>
        /// 主键 char(32)
        /// </summary>
        [DataMember]
        public dynamic Id
        {
            get { return this._Id; }
            set { this._Id = value; }
        }

        /// <summary>
        /// 姓名
        /// </summary>
        private string _Name = null;
        /// <summary>
        /// 姓名 nvarchar(50)
        /// </summary>
        [DataMember]
        public string Name
        {
            get { return this._Name; }
            set { this._Name = value; }
        }

        /// <summary>
        /// 状态
        /// </summary>
        private int _State = int.MinValue;
        /// <summary>
        /// 状态 int
        /// </summary>
        [DataMember]
        public int State
        {
            get { return this._State; }
            set { this._State = value; }
        }

        /// <summary>
        /// 地区
        /// </summary>
        private string _RegionId = null;
        /// <summary>
        /// 地区 nvarchar(32)
        /// </summary>
        [DataMember]
        public string RegionId
        {
            get { return this._RegionId; }
            set { this._RegionId = value; }
        }

        #endregion

        #region 方法

        /// <summary>
        /// 转化实体
        /// </summary>
        public void Convert(System.Data.DataRow row)
        {
            if (row.Table.Columns.Contains(yule.Model.Sys.User.Field.Id) == true)
            {
                this.Id = yule.Util.Convert.ToString(row[yule.Model.Sys.User.Field.Id]);
            }
            if (row.Table.Columns.Contains(yule.Model.Sys.User.Field.Name) == true)
            {
                this.Name = yule.Util.Convert.ToString(row[yule.Model.Sys.User.Field.Name]);
            }
            if (row.Table.Columns.Contains(yule.Model.Sys.User.Field.State) == true)
            {
                this.State = yule.Util.Convert.ToInt(row[yule.Model.Sys.User.Field.State]);
            }
            if (row.Table.Columns.Contains(yule.Model.Sys.User.Field.RegionId) == true)
            {
                this.RegionId = yule.Util.Convert.ToString(row[yule.Model.Sys.User.Field.RegionId]);
            }
        }

        public static yule.Model.Sys.User Select(dynamic id)
        {

            yule.Model.Sys.User model = yule.Common.CacheManager.Cache.Get<yule.Model.Sys.User>(id);

            if (model == null)
            {
                model = yule.Common.ServiceManager.ServiceContext.CreateService<yule.IDAL.Sys.IUser>().Select(id);
            }

            return model;
        }

        #endregion

        #region 表

        /// <summary>
        /// 表
        /// </summary>
        public struct Table
        {
            /// <summary>
            /// 表名
            /// </summary>
            public const string Name = "Sys_User";
        }

        #endregion

        #region 字段

        /// <summary>
        /// 字段
        /// </summary>
        public struct Field
        {
            /// <summary>
            /// 主键
            /// </summary>
            public const string Id = "Id";
            /// <summary>
            /// 姓名
            /// </summary>
            public const string Name = "Name";
            /// <summary>
            /// 状态
            /// </summary>
            public const string State = "State";
            /// <summary>
            /// 地区
            /// </summary>
            public const string RegionId = "RegionId";
        }

        #endregion

        #region 属性

        /// <summary>
        /// 属性
        /// </summary>
        public struct Property
        {
            /// <summary>
            /// 主键
            /// </summary>
            public const string Id = "Id";
            /// <summary>
            /// 姓名
            /// </summary>
            public const string Name = "Name";
            /// <summary>
            /// 状态
            /// </summary>
            public const string State = "State";
            /// <summary>
            /// 地区
            /// </summary>
            public const string RegionId = "RegionId";
        }

        #endregion

    }
}